/**
 * 
 */
package uit.comstore.model.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * @author XIII
 *
 */
@Entity
@Table(name="Deliveries")
@SuppressWarnings("serial")
public class Delivery implements Serializable {

	private Long id;
	private Date dateDelivered;
	private BigDecimal total;
	
	private Order order;
	private Set<DeliveryDetail> deliveryDetail = new HashSet<DeliveryDetail>();
	
	@Id
	@GeneratedValue
	@Column(name="DeliveriesId")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name="DateDelivered")
	public Date getDateDelivered() {
		return dateDelivered;
	}
	public void setDateDelivered(Date dateDelivered) {
		this.dateDelivered = dateDelivered;
	}
	
	@Column(name="DeliveriesTotal")
	public BigDecimal getTotal() {
		return total;
	}
	public void setTotal(BigDecimal total) {
		this.total = total;
	}
	
	@OneToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="OrdersId", referencedColumnName="OrdersId")
	public Order getOrder() {
		return order;
	}
	public void setOrder(Order order) {
		this.order = order;
	}
	
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name="DeliveriesId", referencedColumnName="DeliveriesId")
	public Set<DeliveryDetail> getDeliveryDetail() {
		return deliveryDetail;
	}
	public void setDeliveryDetail(Set<DeliveryDetail> deliveryDetail) {
		this.deliveryDetail = deliveryDetail;
	}
}
